package com.mmall.concurrency.AQS;

import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

@Slf4j
public class FutureTaskDemo {

    public static void main(String[] args) throws Exception {

        FutureTask<String> futureTask = new FutureTask<String>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                log.info("do something in callable!");
                Thread.sleep(5000);
                return "Done OK!";
            }
        });

        new Thread(futureTask).start();
        log.info("do in main!");
        Thread.sleep(2000);
        String result = futureTask.get();
        log.info("yp:{}", result);

    }
}
